# 目标是将已经准备好的data文件进行读取，并将其内容进行倒序排序，最终以转置形式输出
import xlrd
import xlwt

wb = xlrd.open_workbook('test.xls')
table = wb.sheets()[0]

data_lst = []
for i in range(table.nrows):
    data_lst.append(table.row_values(i))
# 倒序
reverse_lst = data_lst[::-1]
# 最后一行是标题  提到第一行
item = reverse_lst.pop(-1)
reverse_lst.insert(0, item)

new_wb = xlwt.Workbook()
table2 = new_wb.add_sheet('data')
for i in range(2):
    for j in range(9):
        table2.write(i, j, reverse_lst[j][i])

new_wb.save('data_new.xls')
